const baseUrl = "http://47.111.24.97:8083"


function requst(method, path, data) {
	return new Promise(result => {
		uni.request({
			url: baseUrl + path,
			method: method,
			header: {
				"Authorization": "",
				// 这个要传空
				'Device': "android"
				// 'Content-Type': 'application/json',
			},
			data,
			success: res => {
				result(res)
			}
		})
	})
}

// 登陆
const loging = (Authorization, username, password) => {
  const url = `/AppApi/users/login?Authorization=${Authorization}&username=${username}&password=${password}`;
  return requst('post', url);
};
// 注册
const register = (type, external_name, external_uid,token,password,head_license,car_no,user_type,data) => {
  const url = `/AppApi/users/oauth?type=${type}
&external_name=${external_name}
&external_uid=${external_uid}
&token=${token}
&password=${password}
&head_license=${head_license}
&user_type=${user_type}`;
  return requst('post', url, data);
}
// 注册验证码
const registerCode = (Authorization,mobile,type,key,data) => {
	const url = `/AppApi/users/sendMsg?Authorization=${Authorization}&mobile=${mobile}&type=${type}`;
	return requst("post",url,data)
};
// 验证码登录
const codeLogin = (username,code,data) => {
	const url = `/AppApi/users/code-login?username=${username}&code=${code}`
	return requst("post",url,data)
}
// 退出登陆
const Logout = (data) => {
	const url = "/AppApi/users/logout"
	return requst("post",url,data)
}

// 首页轮播图
const banner = (page,num,parkId,data) => {
	const url = `/AppApi/home/banner?page=${page}&num=${num}&parkId=${parkId}`
	return requst("get",url,data)
}
// // 园区咨询
// const Party = (type,park_id,page,num,data)=>{
// 	const url = `/AppApi/home/article?type=${type}&park_id=${park_id}&page=${page}&num=${num}`
// 	return requst("get",url,data)
// }

// 园区列表
const park = (data) => {
	const url = "/AppApi/parkList"
	return requst("get", url, data)
}
// 资产管理
const Assets = (Authorization,page,size,data) => {
	const url = `/AppApi/assets_detail?Authorization=${Authorization}&page=${page}&size=${size}`
	return requst("post", url, data)
}
export {
	loging, //登陆
	register,//注册
	registerCode, //获取验证码
	codeLogin,//验证码登陆
	Logout, //退出登陆
	banner,//轮播图
	// Solar,//园区数据
	// Guang,//光伏
	park,
	Assets //资产管理
}
